<div style="float:left; padding-top:5px; padding-left:5px;">
	<div style="padding:5px; overflow:auto;">
		<?php
			if(!empty($uri_var[2])){$filetype = $uri_var[2];}else{$filetype = "";}
			if(!empty($uri_var[3])){$filename = $uri_var[3];}else{$filename = "";}
			
			$filename_explode_parameter = explode("?",$filename);
			if(isset($filename_explode_parameter))
			{
				$filename = $filename_explode_parameter[0];
			}
			else
			{
				$filename = $filename;
			}
			
		?>
				<span class="<?php if($filetype == "management"){echo "submenu_string_red";}else if($filetype == "module"){echo "submenu_string_blue";} ?>"><?php echo strtoupper(strtolower($filetype)); ?></span>
		<?php
			
			/*
			$sql2 = "select * from ms_module_sub where modulesuburltype = '".$filetype."' and moduleid = '".$moduleid."' order by modulesubposition asc ";
			//echo $sql2;die();
			$exe2 = mysql_query($sql2);
			*/
			
			if($filetype == "module")
			{
				$sql2 = "
					select distinct a.moduleurlback as backurl, a.moduleid as id, a.modulelabel as label, a.modulestatus as status
					from ms_module a
				";
				if($_SESSION['usergroupid'] != 1)
				{
				$sql2 .= "
						left join ms_module_group_privilege b
							on a.moduleid = b.modulegroupprivilegemoduleid and b.modulegroupprivilegetype = 'module' and b.modulegroupprivilegemodulesubid = 0 and b.stsrc = 'A'
					where b.modulegroupprivilegeenable = 1 and b.modulegroupprivilegetype = 'module' and b.modulegroupprivilegemodulesubid = 0 and b.usergroupid = ".$_SESSION['usergroupid']." and a.stsrc = 'A'
				";
				}
				else
				{
				$sql2 .= "
					where a.stsrc = 'A'
				";
				}
				$sql2 .= "
					order by a.moduleposition asc
				";
			}
			else if($filetype == "management")
			{
				$sql2 = "
					select distinct a.moduleadminurlback as backurl, a.moduleadminid as id, a.moduleadminlabel as label, '1' as status
					from ms_module_admin a
				";
				if($_SESSION['usergroupid'] != 1)
				{
				$sql2 .= "
						left join ms_module_group_privilege b
							on a.moduleadminid = b.modulegroupprivilegemoduleid and b.modulegroupprivilegetype = 'management' and b.modulegroupprivilegemodulesubid = 0 and b.stsrc = 'A'
					where b.modulegroupprivilegeenable = 1 and b.modulegroupprivilegetype = 'management' and b.modulegroupprivilegemodulesubid = 0 and b.usergroupid = ".$_SESSION['usergroupid']." and a.stsrc = 'A'
				";
				}
				else
				{
				$sql2 .= "
					where a.stsrc = 'A'
				";
				}
				$sql2 .= "
					order by a.moduleadminposition asc 
				";
			}
			//echo $sql2;die();
			$exe2 = mysql_query($sql2);
		?>
			<ul id="navigation" class="filetree">
		<?php
			while ($row2 = mysql_fetch_array($exe2))
			{
		?>
				<li <?php if(SUBMENU_CHILD_EXPAND == 1){ ?>class="open" <?php } ?>>
					<a href="<?php echo URL_HOME_SITE_ADMIN; ?>/<?php echo $filetype; ?>/<?php echo $row2['backurl']; ?>">
						<span><?php echo ucwords(strtolower($row2['label'])); ?></span>
						<?php if($row2['status'] != 1){echo "<span style='color:red;'>&bull;OFF</span>";} ?>
					</a>
				<?php
					if(1==1)	// turn on / off modulesub
					{
						$sql4 = "	select * from ms_module_sub a
								";
						if($_SESSION['usergroupid'] != 1)
						{
						$sql4 .= "
									left join ms_module_group_privilege b
										on a.moduleid = b.modulegroupprivilegemoduleid 
											and a.modulesubid = b.modulegroupprivilegemodulesubid
											and a.modulesuburltype = b.modulegroupprivilegetype
											and b.stsrc = 'A'
								";
						}
						$sql4 .= "
									where a.modulesuburltype = '".$filetype."' 
										and a.moduleid = '".$row2['id']."' 
										and a.stsrc = 'A' 
								";
						if($_SESSION['usergroupid'] != 1)
						{
						$sql4 .= "
										and b.modulegroupprivilegeenable = 1
										and b.modulegroupprivilegetype = '".$filetype."'
										and b.usergroupid = ".$_SESSION['usergroupid']."
						";
						}
						$sql4 .= "
									order by a.modulesubposition asc
								";
						//echo $sql4;die();
						$exe4 = mysql_query($sql4);
						$num4 = mysql_num_rows($exe4);
						
						if($num4>0)
						{
				?>
					<ul>
				<?php
							while ($row4 = mysql_fetch_array($exe4))
							{
				?>
							<li>
								<a <?php if($row4['modulesuburlback'] == $filename){echo "class='selected'";} ?> href="<?php echo URL_HOME_SITE_ADMIN; ?>/<?php echo $filetype; ?>/<?php echo $row4['modulesuburlback']; ?>">
									<span><?php echo ucwords(strtolower($row4['modulesublabel'])); ?></span>
									<?php if($row4['modulesubstatus'] != 1){echo "<span style='color:red;'>&bull;OFF</span>";} ?>
								</a>
							</li>
							<?php
								if(1==0)	// turn on / off modulesub2
								{
									$sql3 = "	select * from ms_module_sub_2 
												where modulesub2urltype = '".$filetype."' 
													and modulesubid = '".$row4['modulesubid']."' 
													and stsrc = 'A' 
												order by modulesub2position asc 
											";
									//echo $sql3;//die();
									$exe3 = mysql_query($sql3);
									$num3 = mysql_num_rows($exe3);
									
									if($num3>0)
									{
							?>
								<ul>
							<?php
										while ($row3 = mysql_fetch_array($exe3))
										{
							?>
									<li><span><a href="<?php echo URL_HOME_SITE_ADMIN; ?>/<?php echo $filetype; ?>/<?php echo $row3['modulesub2urlback']; ?>"><?php echo ucwords(strtolower($row3['modulesub2label'])); ?></a></span>
									</li>
							<?php
										}
							?>
								</ul>
							<?php
									}
								}
							?>
			<?php
							}
			?>
					</ul>
			<?php
						}
					}
			?>
				</li>
		<?php
			}
		?>
			</ul>
	</div>
</div>
<div style="clear:both;"></div>